import React, {Component} from 'react';
import {ToDo} from "../ToDoList";

type IProps = {
    toDoList: ToDo[],
    selectAll: any
}

class Footer extends Component<IProps> {

    constructor(props: IProps) {
        super(props);

    }


    render() {
        let {toDoList, selectAll} = this.props;
        let doCount = toDoList.reduce(((previousValue, currentValue) => previousValue + (currentValue.isChecked ? 1 : 0)), 0)
        let count = toDoList.length
        let isChecked = doCount == count && doCount !== 0;
        return (
            <div>
                <input onChange={selectAll} checked={isChecked} type={"checkbox"}/>已做{doCount}项/共{count}项
            </div>
        );
    }
}

export default Footer;